package org.demis.troll.helper;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class NameHelper {

    private final Log logger = LogFactory.getLog(NameHelper.class);

    private static NameHelper instance = new NameHelper();

    private NameHelper() {
        // no op
    }

    public static NameHelper getInstance() {
        return instance;
    }

    public String toUpperCaseFirstLetter(String value) {
        if (StringUtils.isEmpty(value)) {
            return value;
        }
        else if (value.length() == 1) {
            return value.toUpperCase();
        }
        else {
            return value.substring(0, 1).toUpperCase() + value.substring(1);
        }
    }

    public String toLowerCaseFirstLetter(String value) {
        if (StringUtils.isEmpty(value)) {
            return value;
        }
        else if (value.length() == 1) {
            return value.toLowerCase();
        }
        else {
            return value.substring(0, 1).toLowerCase() + value.substring(1);
        }
    }

    public String removeLastLetter(String value) {
        if (StringUtils.isEmpty(value)) {
            return value;
        }
        else if (value.length() == 1) {
            return "";
        }
        else {
            return value.substring(0, value.length()-1);
        }
    }
}
